<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>登录</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vant@1.6/lib/index.css">
		<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.min.js"></script>
		<script src="https://cdn.jsdelivr.net/npm/vant@1.6/lib/vant.min.js"></script>
		<script src="../../js/ajax.js" type="text/javascript" charset="utf-8"></script>
		<script src="html5plus://ready"></script>		
	</head>
	<body>
		<div id="app">
			<van-nav-bar  @click-left="onClickLeft" title="登录" left-text="返回" left-arrow id="a">
			</van-nav-bar>
			<head style="height: 200px;">
				<img src="../../img/touxiang.jpg" style="height: 60px;width: 60px; margin:90px 150px 0px 150px;width: 100px;
				height: 100px;
				border-radius: 50%;"/>
			</head>
			<section>
				<van-cell-group style="margin-top: 30px;">
					<van-field left-icon="phone" v-model="phone" placeholder="手机号" style="margin-top: 20px;"></van-field>
					<van-field left-icon="wap-home" type="password" v-model="pwd" placeholder="登录密码" style="margin-top: 10px;"></van-field>
				</van-cell-group>
				<a href="#" @click="wangji">
					<label style="float: right;">忘记密码</label>
				</a>
				<van-button size="large" type="danger" style="margin-top: 20px;" @click="login">立即登录</van-button>
				<van-row>
					<van-col span="24" style="text-align: center; padding-top: 10px;">
						<a href="#" @click="zhuce">
							<label>还没有注册？点我立即注册哦!</label>
						</a>
					</van-col>
				</van-row>
				
			</section>
			<footer>

			</footer>
		</div>
		<script>
			var vm = new Vue({
				el: "#app",
				data: {
					phone:"",
					pwd: ""
				},
				methods: {
					onClickLeft: function() {
						plus.webview.close(plus.webview.currentWebview(), "slide-out-left");
						console.log("返回个人页面")
					},
					login: function() {
						//console.log(123);
						var _this=this;
						console.log("登录");
						ajax({ //登录
								url: "http://dsapi.ysd3g.com/api/login",
								dataType: "jsonp",
								data: {
 									account:_this.phone,
 									password:_this.pwd								
								},
								success: function(res) {
									if(res.Error){
										vm.$toast("账号或密码输入错误，请重新输入！");
									}else{
										var personal=plus.webview.getWebviewById("abc");
										console.log(personal);
										personal.reload(true);
										var User=JSON.stringify(res);//把Json格式的用户信息转换成字符串存放到变量里
										localStorage.setItem("user",User);//存放到localStroage里
										vm.$toast("登录成功,三秒钟后跳转...");
										plus.webview.close(plus.webview.currentWebview(),"slide-out-left");
										window.setTimeout(function() {
											plus.webview.open("abc.html", "abc");
										}, 3000);
									}
									console.log(res);
								}
							});
						
					},
					wangji: function() {
						console.log("忘记密码")
					},
					zhuce:function(){//注册
						plus.webview.open("zhuce.html", "zhuce");
						console.log("注冊")
					}
				}
			})
		</script>
	</body>
</html>